<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Bitnik::Apm::Builder</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Bitnik::Apm::Builder</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/lib/apm_builder_rb.html">
                lib/apm_builder.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Object
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Class that implements an algorithm to build an APML file from an
AttentionSource object.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000071">build_profile_for</a>&nbsp;&nbsp;
      <a href="#M000072">compute_attention</a>&nbsp;&nbsp;
      <a href="#M000070">new</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">default_profile</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">from</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">generator</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">title</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">user_email</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">version</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000070" class="method-detail">
        <a name="M000070"></a>

        <div class="method-heading">
          <a href="#M000070" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(calculator=nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Constructor Parameters:
</p>
<ul>
<li>calculator an object that implements the method <a
href="Builder.html#M000072">compute_attention</a>(concept,mode,value,total_attention_value)
used

<pre>
           to calculate the attention APML attribute for an AttentionDestiny or AttentionDestinyReference.
           If none is provided, the proportional value of each destiny will be used as the value for the implicit
           concepts and sources. The sum of the attention points will be used for explicit elements.
</pre>
</li>
</ul>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000070-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000070-source">
<pre>
    <span class="ruby-comment cmt"># File lib/apm_builder.rb, line 19</span>
19:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">calculator</span>=<span class="ruby-keyword kw">nil</span>)
20:         <span class="ruby-ivar">@version</span>=<span class="ruby-value str">&quot;0.6&quot;</span>
21:         <span class="ruby-ivar">@title</span>=<span class="ruby-value str">&quot;APML file&quot;</span>
22:         <span class="ruby-ivar">@generator</span> = <span class="ruby-value str">&quot;apm bintik ruby on rails plugin&quot;</span>
23:         <span class="ruby-ivar">@default_profile</span> = <span class="ruby-keyword kw">nil</span>
24:         <span class="ruby-ivar">@from</span> = <span class="ruby-value str">&quot;bitnik.apml.plugin&quot;</span>
25:         <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">calculator</span><span class="ruby-operator">==</span><span class="ruby-keyword kw">nil</span>)
26:           <span class="ruby-ivar">@calculator</span> = <span class="ruby-keyword kw">self</span>
27:         <span class="ruby-keyword kw">else</span>
28:           <span class="ruby-ivar">@calculator</span> = <span class="ruby-identifier">calculator</span>
29:         <span class="ruby-keyword kw">end</span>
30: 
31:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000071" class="method-detail">
        <a name="M000071"></a>

        <div class="method-heading">
          <a href="#M000071" class="method-signature">
          <span class="method-name">build_profile_for</span><span class="method-args">(attention_consumer)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Builds the APML file for an AttentionSource object.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000071-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000071-source">
<pre>
     <span class="ruby-comment cmt"># File lib/apm_builder.rb, line 34</span>
 34:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build_profile_for</span>(<span class="ruby-identifier">attention_consumer</span>)
 35:         <span class="ruby-identifier">xml</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>
 36: 
 37:         <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">'&lt;?xml version=&quot;1.0&quot;?&gt;'</span>
 38:         <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;APML xmlns=\&quot;http://www.apml.org/apml-&quot;</span><span class="ruby-operator">+</span><span class="ruby-ivar">@version</span><span class="ruby-operator">+</span><span class="ruby-value str">&quot;\&quot; version=\&quot;&quot;</span><span class="ruby-operator">+</span><span class="ruby-ivar">@version</span><span class="ruby-operator">+</span><span class="ruby-value str">&quot;\&quot; &gt;&quot;</span>
 39:         <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;Head&gt;&quot;</span>
 40:         <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;Title&gt;#{@title}&lt;/Title&gt;&quot;</span>
 41:         <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;Generator&gt;#{@generator}&lt;/Generator&gt;&quot;</span>
 42:         <span class="ruby-keyword kw">if</span>(<span class="ruby-ivar">@user_email!</span>=<span class="ruby-keyword kw">nil</span>)
 43:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;User-Email&gt;#{user_email}&lt;/User-Email&gt;&quot;</span>
 44:         <span class="ruby-keyword kw">end</span>
 45:         <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;DateCreated&gt;#{Time.now.xmlschema}&lt;/DateCreated&gt;&quot;</span>
 46:         <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/Head&gt;&quot;</span>
 47:         <span class="ruby-keyword kw">if</span>(<span class="ruby-ivar">@default_profile!</span>=<span class="ruby-keyword kw">nil</span>)
 48:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;Body defaultprofile=\&quot;#{@default_profile}\&quot;&gt;&quot;</span>
 49:         <span class="ruby-keyword kw">else</span>
 50:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;Body&gt;&quot;</span>
 51:         <span class="ruby-keyword kw">end</span>
 52:         <span class="ruby-identifier">total_value</span> = <span class="ruby-identifier">attention_consumer</span>.<span class="ruby-identifier">compute_total_implicit_attention_value</span>
 53:         <span class="ruby-identifier">attention_consumer</span>.<span class="ruby-identifier">attention_profiles</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">profile</span><span class="ruby-operator">|</span>
 54:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;Profile name=\&quot;#{profile.name}\&quot;&gt;&quot;</span>
 55:           <span class="ruby-ivar">@implicit_mapping</span> = <span class="ruby-identifier">attention_consumer</span>.<span class="ruby-identifier">build_implicit_attention_profile_mapping</span>(<span class="ruby-identifier">profile</span>)
 56:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;ImplicitData&gt;&lt;Concepts&gt;&quot;</span>
 57:           <span class="ruby-ivar">@implicit_mapping</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">concept</span>,<span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
 58:             <span class="ruby-identifier">computed</span> = <span class="ruby-ivar">@calculator</span>.<span class="ruby-identifier">compute_attention</span>(<span class="ruby-identifier">concept</span>,<span class="ruby-identifier">:implicit</span>,<span class="ruby-identifier">value</span>,<span class="ruby-identifier">total_value</span>)
 59:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">concept</span>.<span class="ruby-identifier">attention_destiny</span>.<span class="ruby-identifier">from</span><span class="ruby-operator">==</span><span class="ruby-keyword kw">nil</span>)
 60:               <span class="ruby-identifier">from</span> = <span class="ruby-ivar">@from</span>
 61:             <span class="ruby-keyword kw">else</span>
 62:               <span class="ruby-identifier">from</span> = <span class="ruby-identifier">concept</span>.<span class="ruby-identifier">attention_destiny</span>.<span class="ruby-identifier">from</span>
 63:             <span class="ruby-keyword kw">end</span>
 64:             <span class="ruby-identifier">updated</span> = <span class="ruby-identifier">concept</span>.<span class="ruby-identifier">attention_destiny</span>.<span class="ruby-identifier">updated_at</span>.<span class="ruby-identifier">xmlschema</span>
 65:             <span class="ruby-identifier">name</span> = <span class="ruby-identifier">concept</span>.<span class="ruby-identifier">attention_destiny</span>.<span class="ruby-identifier">key</span>
 66:             <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;Concept key=\&quot;#{name}\&quot; value=\&quot;#{computed}\&quot; from=\&quot;#{from}\&quot; updated=\&quot;#{updated}\&quot; /&gt;&quot;</span>
 67:           <span class="ruby-keyword kw">end</span>
 68:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/Concepts&gt;&quot;</span>
 69:           <span class="ruby-ivar">@implicit_references_mapping</span> = <span class="ruby-identifier">attention_consumer</span>.<span class="ruby-identifier">build_implicit_attention_reference_profile_mapping</span>(<span class="ruby-identifier">profile</span>)
 70:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;Sources&gt;&quot;</span>
 71:           <span class="ruby-ivar">@implicit_references_mapping</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ref</span>,<span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
 72:             <span class="ruby-identifier">computed</span> = <span class="ruby-ivar">@calculator</span>.<span class="ruby-identifier">compute_attention</span>(<span class="ruby-identifier">ref</span>,<span class="ruby-identifier">:implicit</span>,<span class="ruby-identifier">value</span>,<span class="ruby-identifier">total_value</span>)
 73:             <span class="ruby-identifier">from</span> = <span class="ruby-identifier">ref</span>.<span class="ruby-identifier">from</span>
 74:             <span class="ruby-identifier">key</span> = <span class="ruby-identifier">ref</span>.<span class="ruby-identifier">key</span>
 75:             <span class="ruby-identifier">name</span> = <span class="ruby-identifier">ref</span>.<span class="ruby-identifier">name</span>
 76:             <span class="ruby-identifier">type</span> = <span class="ruby-identifier">ref</span>.<span class="ruby-identifier">mime_type</span>
 77:             <span class="ruby-identifier">updated</span> = <span class="ruby-identifier">ref</span>.<span class="ruby-identifier">updated_at</span>.<span class="ruby-identifier">xmlschema</span>
 78:             <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;Source&quot;</span>
 79:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">key!</span>=<span class="ruby-keyword kw">nil</span>)
 80:               <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; key=\&quot;#{key}\&quot;&quot;</span>
 81:             <span class="ruby-keyword kw">end</span>
 82:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">name!</span>=<span class="ruby-keyword kw">nil</span>)
 83:               <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; name=\&quot;#{name}\&quot;&quot;</span>
 84:             <span class="ruby-keyword kw">end</span>
 85:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">type!</span>=<span class="ruby-keyword kw">nil</span>)
 86:               <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; type=\&quot;#{type}\&quot;&quot;</span>
 87:             <span class="ruby-keyword kw">end</span>
 88:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">from!</span>=<span class="ruby-keyword kw">nil</span>)
 89:               <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; from=\&quot;#{from}\&quot;&quot;</span>
 90:             <span class="ruby-keyword kw">end</span>
 91:             <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; value=\&quot;#{computed}\&quot;&quot;</span>
 92:             <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; updated=\&quot;#{updated}\&quot;&gt;&quot;</span>
 93:             <span class="ruby-identifier">author</span> = <span class="ruby-identifier">ref</span>.<span class="ruby-identifier">author</span>
 94:             <span class="ruby-identifier">key</span> = <span class="ruby-identifier">author</span>.<span class="ruby-identifier">key</span>
 95:             <span class="ruby-identifier">value</span> = <span class="ruby-identifier">author</span>.<span class="ruby-identifier">value</span>
 96:             <span class="ruby-identifier">from</span> = <span class="ruby-identifier">author</span>.<span class="ruby-identifier">value</span>
 97:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">author</span>.<span class="ruby-identifier">updated_at!</span>=<span class="ruby-keyword kw">nil</span>)
 98:               <span class="ruby-identifier">updated</span> = <span class="ruby-identifier">author</span>.<span class="ruby-identifier">updated_at</span>.<span class="ruby-identifier">xmlschema</span>
 99:             <span class="ruby-keyword kw">else</span>
100:               <span class="ruby-identifier">updated</span>=<span class="ruby-keyword kw">nil</span>
101:             <span class="ruby-keyword kw">end</span>
102: 
103:             <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;Author&quot;</span>
104:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">key!</span>=<span class="ruby-keyword kw">nil</span>)
105:               <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; key=\&quot;#{key}\&quot;&quot;</span>
106:             <span class="ruby-keyword kw">end</span>
107:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">value!</span>=<span class="ruby-keyword kw">nil</span>)
108:               <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; value=\&quot;#{value}\&quot;&quot;</span>
109:             <span class="ruby-keyword kw">end</span>
110:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">from!</span>=<span class="ruby-keyword kw">nil</span>)
111:               <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; from=\&quot;#{from}\&quot;&quot;</span>
112:             <span class="ruby-keyword kw">end</span>
113:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">updated!</span>=<span class="ruby-keyword kw">nil</span>)
114:               <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; updated=\&quot;#{updated}\&quot;&quot;</span>
115:             <span class="ruby-keyword kw">end</span>
116:             <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot; /&gt;&quot;</span>
117: 
118:             <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/Source&gt;&quot;</span>
119:           <span class="ruby-keyword kw">end</span>
120:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/Sources&gt;&quot;</span>
121:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/ImplicitData&gt;&quot;</span>
122: 
123:           <span class="ruby-ivar">@explicit_mapping</span> = <span class="ruby-identifier">attention_consumer</span>.<span class="ruby-identifier">build_explicit_attention_profile_mapping</span>(<span class="ruby-identifier">profile</span>)
124:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;ExplicitData&gt;&lt;Concepts&gt;&quot;</span>
125:           <span class="ruby-ivar">@explicit_mapping</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">concept</span>,<span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
126:             <span class="ruby-comment cmt">#computed = @calculator.compute_attention(concept,:explicit,value,total_value)</span>
127:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">concept</span>.<span class="ruby-identifier">attention_destiny</span>.<span class="ruby-identifier">from</span><span class="ruby-operator">==</span><span class="ruby-keyword kw">nil</span>)
128:               <span class="ruby-identifier">from</span> = <span class="ruby-ivar">@from</span>
129:             <span class="ruby-keyword kw">else</span>
130:               <span class="ruby-identifier">from</span> = <span class="ruby-identifier">concept</span>.<span class="ruby-identifier">attention_destiny</span>.<span class="ruby-identifier">from</span>
131:             <span class="ruby-keyword kw">end</span>
132:             <span class="ruby-identifier">updated</span> = <span class="ruby-identifier">concept</span>.<span class="ruby-identifier">attention_destiny</span>.<span class="ruby-identifier">updated_at</span>.<span class="ruby-identifier">xmlschema</span>
133:             <span class="ruby-identifier">name</span> = <span class="ruby-identifier">concept</span>.<span class="ruby-identifier">attention_destiny</span>.<span class="ruby-identifier">key</span>
134:             <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;Concept key=\&quot;#{name}\&quot; value=\&quot;#{value}\&quot;/&gt;&quot;</span>
135:           <span class="ruby-keyword kw">end</span>
136:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/Concepts&gt;&quot;</span>
137: 
138:           <span class="ruby-ivar">@explicit_references_mapping</span> = <span class="ruby-identifier">attention_consumer</span>.<span class="ruby-identifier">build_explicit_attention_reference_profile_mapping</span>(<span class="ruby-identifier">profile</span>)
139:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;Sources&gt;&quot;</span>
140:           <span class="ruby-ivar">@explicit_references_mapping</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ref</span>,<span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
141:             <span class="ruby-identifier">from</span> = <span class="ruby-identifier">ref</span>.<span class="ruby-identifier">from</span>
142:             <span class="ruby-identifier">key</span> = <span class="ruby-identifier">ref</span>.<span class="ruby-identifier">key</span>
143:             <span class="ruby-identifier">name</span> = <span class="ruby-identifier">ref</span>.<span class="ruby-identifier">name</span>
144:             <span class="ruby-identifier">type</span> = <span class="ruby-identifier">ref</span>.<span class="ruby-identifier">mime_type</span>
145:             <span class="ruby-identifier">updated</span> = <span class="ruby-identifier">ref</span>.<span class="ruby-identifier">updated_at</span>.<span class="ruby-identifier">xmlschema</span>
146:             <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;Source&quot;</span>
147:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">key!</span>=<span class="ruby-keyword kw">nil</span>)
148:               <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; key=\&quot;#{key}\&quot;&quot;</span>
149:             <span class="ruby-keyword kw">end</span>
150:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">name!</span>=<span class="ruby-keyword kw">nil</span>)
151:               <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; name=\&quot;#{name}\&quot;&quot;</span>
152:             <span class="ruby-keyword kw">end</span>
153:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">type!</span>=<span class="ruby-keyword kw">nil</span>)
154:               <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; type=\&quot;#{type}\&quot;&quot;</span>
155:             <span class="ruby-keyword kw">end</span>
156:             <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; value=\&quot;#{value}\&quot;&quot;</span>
157:             <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">' &gt;'</span>
158: 
159:             <span class="ruby-identifier">author</span> = <span class="ruby-identifier">ref</span>.<span class="ruby-identifier">author</span>
160:             <span class="ruby-identifier">key</span> = <span class="ruby-identifier">author</span>.<span class="ruby-identifier">key</span>
161:             <span class="ruby-identifier">value</span> = <span class="ruby-identifier">author</span>.<span class="ruby-identifier">value</span>
162:             <span class="ruby-identifier">from</span> = <span class="ruby-identifier">author</span>.<span class="ruby-identifier">value</span>
163:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">author</span>.<span class="ruby-identifier">updated_at!</span>=<span class="ruby-keyword kw">nil</span>)
164:               <span class="ruby-identifier">updated</span> = <span class="ruby-identifier">author</span>.<span class="ruby-identifier">updated_at</span>.<span class="ruby-identifier">xmlschema</span>
165:             <span class="ruby-keyword kw">else</span>
166:               <span class="ruby-identifier">updated</span>=<span class="ruby-keyword kw">nil</span>
167:             <span class="ruby-keyword kw">end</span>
168: 
169:             <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;Author&quot;</span>
170:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">key!</span>=<span class="ruby-keyword kw">nil</span>)
171:               <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; key=\&quot;#{key}\&quot;&quot;</span>
172:             <span class="ruby-keyword kw">end</span>
173:             <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">value!</span>=<span class="ruby-keyword kw">nil</span>)
174:               <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; value=\&quot;#{value}\&quot;&quot;</span>
175:             <span class="ruby-keyword kw">end</span>
176:             <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot; /&gt;&quot;</span>
177: 
178:             <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/Source&gt;&quot;</span>
179:           <span class="ruby-keyword kw">end</span>
180:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/Sources&gt;&quot;</span>
181: 
182:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/ExplicitData&gt;&quot;</span>
183:           <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/Profile&gt;&quot;</span>
184:         <span class="ruby-keyword kw">end</span>
185:         <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/Body&gt;&quot;</span>
186:         <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/APML&gt;&quot;</span>
187: 
188:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">string</span>
189:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000072" class="method-detail">
        <a name="M000072"></a>

        <div class="method-heading">
          <a href="#M000072" class="method-signature">
          <span class="method-name">compute_attention</span><span class="method-args">(concept,mode,value,total_attention_value)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Default attention calcule algorithm.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000072-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000072-source">
<pre>
     <span class="ruby-comment cmt"># File lib/apm_builder.rb, line 192</span>
192:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compute_attention</span>(<span class="ruby-identifier">concept</span>,<span class="ruby-identifier">mode</span>,<span class="ruby-identifier">value</span>,<span class="ruby-identifier">total_attention_value</span>)
193:         <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">total_attention_value!</span>=<span class="ruby-value">0</span>)
194:           <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_f</span><span class="ruby-operator">/</span><span class="ruby-identifier">total_attention_value</span>.<span class="ruby-identifier">to_f</span>
195:         <span class="ruby-keyword kw">else</span>
196:           <span class="ruby-value">0</span>
197:         <span class="ruby-keyword kw">end</span>
198:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>